/*
 * ModelChangedEvent.java
 *
 * Created on 7-Mar-2010.
 */

package org.calendar.event;


import java.util.EventObject;
import java.util.Calendar;
import java.util.Locale;


/**
 * This class holds information related to a calendar change in the model
 *
 * @see org.calendar.DefaultCalendarModel
 * @see org.calendar.JDaySelector
 * @see org.calendar.JMonthNavigator
 * @see java.util.EventObject
 *
 * @author Julie Duvillier
 */

public class ModelChangedEvent
        extends EventObject {

     /** Calendar to be displayed */
    private Calendar calToDisplay = null;

    private Locale locale = null;


    /**
     * Create a model changed event.
     *
     * @param source The model on which the change occurs
     * @param calendar The calendar to be displayed
     * @param locale the local to use
     */
    public ModelChangedEvent(Object source, Calendar calendar, Locale locale){
        super(source);
        this.calToDisplay = calendar;
        this.locale= locale;
    }

    /**
     * Returns the calendar to display
     *
     * @return the calendar to be displayed
     */
    public Calendar getCalendarToDisplay(){
        return calToDisplay;
    }

    /**
     * Return the locale
     * @return  the locale Value
     */
    public Locale getLocale(){
        return locale;
    }

    /**
     * Returns a string containing information about the source
     * and the calendar to display time.
     * @return string containing this object information.
     */
    @Override
    public String toString(){

        String str = super.toString();
            if( calToDisplay != null )
                str = str + "Calendar to Display " +  calToDisplay.getTime();
            if( locale != null )
                 str = str + "Locale " +  locale.getCountry();
        return str;
    }


}
